﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ImagesViewer
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        //====================================================================================================================
        private int currentImage { get; set; }
        private List<string> files = new List<string>();

        private void loadFiles(string fileOrDirectoryName)
        {
            files.Clear(); currentImage = 0;
            string ext = "";
            //
            //
            //
            fileOrDirectoryName = System.IO.Path.GetFullPath(fileOrDirectoryName);
            if(System.IO.Directory.Exists(fileOrDirectoryName))
            {
                ext = ".jpg";
                foreach (string file in System.IO.Directory.EnumerateFiles(fileOrDirectoryName, "*" + ext, System.IO.SearchOption.TopDirectoryOnly))
                {
                    files.Add(file);
                }
            }
            else//file
            {
                ext = System.IO.Path.GetExtension(fileOrDirectoryName);
                string directoryName = System.IO.Path.GetDirectoryName(fileOrDirectoryName);
                foreach (string file in System.IO.Directory.EnumerateFiles(directoryName, "*" + ext, System.IO.SearchOption.TopDirectoryOnly))
                {
                    files.Add(file);
                }
                int n = files.FindIndex(v => v == fileOrDirectoryName);
                if (n >= 0)
                {
                    currentImage = n;
                }
            }
            //
        }
        //====================================================================================================================

        //====================================================================================================================
    }
}
